make tuneing sub-menu.

master
Bernhard Kubicek 13 years ago
parent 15bb3f284e
commit 379ea642e1

@ -252,10 +252,11 @@ void CardReader::openFile(char* name,bool read)
sdpos = 0; sdpos = 0;
SERIAL_PROTOCOLLNPGM("File selected"); SERIAL_PROTOCOLLNPGM("File selected");
LCD_MESSAGE(fname);
} }
else else
{ {
SERIAL_PROTOCOLPGM("open failed, File: "); SERIAL_PROTOCOLPGM("open failed, File: ");
SERIAL_PROTOCOL(fname); SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLLNPGM("."); SERIAL_PROTOCOLLNPGM(".");
} }
@ -273,6 +274,7 @@ void CardReader::openFile(char* name,bool read)
saving = true; saving = true;
SERIAL_PROTOCOLPGM("Writing to file: "); SERIAL_PROTOCOLPGM("Writing to file: ");
SERIAL_PROTOCOLLN(name); SERIAL_PROTOCOLLN(name);
LCD_MESSAGE(fname);
} }
} }

@ -762,3 +762,7 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo
previous_speed[3] = 0.0; previous_speed[3] = 0.0;
} }
uint8_t movesplanned()
{
return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
}

@ -80,6 +80,7 @@ void plan_discard_current_block();
block_t *plan_get_current_block(); block_t *plan_get_current_block();
void check_axes_activity(); void check_axes_activity();
uint8_t movesplanned();
extern unsigned long minsegmenttime; extern unsigned long minsegmenttime;
extern float max_feedrate[4]; // set the max speeds extern float max_feedrate[4]; // set the max speeds

@ -64,6 +64,7 @@
void showStatus(); void showStatus();
void showMainMenu(); void showMainMenu();
void showPrepare(); void showPrepare();
void showTune();
void showControl(); void showControl();
void showControlMotion(); void showControlMotion();
void showControlTemp(); void showControlTemp();
@ -75,6 +76,8 @@
bool linechanging; bool linechanging;
bool tune;
private: private:
inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos) inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
{ {
@ -90,7 +93,6 @@
lineoffset--; lineoffset--;
if(lineoffset<0) lineoffset=0; if(lineoffset<0) lineoffset=0;
curencoderpos=lcdslow-1; curencoderpos=lcdslow-1;
force_lcd_update=true;
} }
if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow) if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
{ {
@ -100,9 +102,9 @@
lineoffset=maxlines+1-LCD_HEIGHT; lineoffset=maxlines+1-LCD_HEIGHT;
if(curencoderpos>maxlines*lcdslow) if(curencoderpos>maxlines*lcdslow)
curencoderpos=maxlines*lcdslow; curencoderpos=maxlines*lcdslow;
force_lcd_update=true;
} }
lastencoderpos=encoderpos=curencoderpos; lastencoderpos=encoderpos=curencoderpos;
int lastactiveline=activeline;
activeline=curencoderpos/lcdslow; activeline=curencoderpos/lcdslow;
if(activeline<0) activeline=0; if(activeline<0) activeline=0;
if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1; if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
@ -111,6 +113,8 @@
activeline=maxlines; activeline=maxlines;
curencoderpos=maxlines*lcdslow; curencoderpos=maxlines*lcdslow;
} }
if(lastactiveline!=activeline ||lastlineoffset!=lineoffset)
force_lcd_update=true;
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003'); lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
} }
} }
@ -126,7 +130,6 @@
}; };
//conversion routines, could need some overworking //conversion routines, could need some overworking
char *fillto(int8_t n,char *c);
char *ftostr51(const float &x); char *ftostr51(const float &x);
char *ftostr31(const float &x); char *ftostr31(const float &x);
char *ftostr3(const float &x); char *ftostr3(const float &x);

@ -65,6 +65,7 @@ inline int intround(const float &x){return int(0.5+x);}
void lcd_status(const char* message) void lcd_status(const char* message)
{ {
strncpy(messagetext,message,LCD_WIDTH); strncpy(messagetext,message,LCD_WIDTH);
messagetext[strlen(message)]=0;
} }
void lcd_statuspgm(const char* message) void lcd_statuspgm(const char* message)
@ -79,6 +80,7 @@ void lcd_statuspgm(const char* message)
cnt++; cnt++;
ch=pgm_read_byte(++message); ch=pgm_read_byte(++message);
} }
*target=0;
} }
inline void clear() inline void clear()
@ -280,6 +282,7 @@ MainMenu::MainMenu()
#endif #endif
lcd_init(); lcd_init();
linechanging=false; linechanging=false;
tune=false;
} }
void MainMenu::showStatus() void MainMenu::showStatus()
@ -373,7 +376,11 @@ void MainMenu::showStatus()
if(messagetext[0]!='\0') if(messagetext[0]!='\0')
{ {
lcd.setCursor(0,LCD_HEIGHT-1); lcd.setCursor(0,LCD_HEIGHT-1);
lcd.print(fillto(LCD_WIDTH,messagetext)); lcd.print(messagetext);
uint8_t n=strlen(messagetext);
for(int8_t i=0;i<LCD_WIDTH-n;i++)
lcd.print(" ");
messagetext[0]='\0'; messagetext[0]='\0';
} }
@ -419,7 +426,10 @@ void MainMenu::showStatus()
if(messagetext[0]!='\0') if(messagetext[0]!='\0')
{ {
lcd.setCursor(0,LCD_HEIGHT-1); lcd.setCursor(0,LCD_HEIGHT-1);
lcd.print(fillto(LCD_WIDTH,messagetext)); lcd.print(messagetext);
uint8_t n=strlen(messagetext);
for(int8_t i=0;i<LCD_WIDTH-n;i++)
lcd.print(" ");
messagetext[0]='\0'; messagetext[0]='\0';
} }
@ -471,6 +481,166 @@ void MainMenu::showPrepare()
updateActiveLines(ItemP_disstep,encoderpos); updateActiveLines(ItemP_disstep,encoderpos);
} }
enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,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( lcdprintPGM(" Tune") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemT_speed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
}
if((activeline==line) )
{
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=feedmultiply;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
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);lcdprintPGM(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
if((activeline==line) )
{
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend0());
}
else
{
setTargetHotend0(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}
}break;
case ItemT_fan:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Fan speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
}
if((activeline==line) )
{
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=fanpwm;
}
else
{
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
fanpwm=encoderpos;
analogWrite(FAN_PIN, fanpwm);
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);lcdprintPGM(" Flow:");
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
}
if((activeline==line) )
{
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3];
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
}
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemT_fan,encoderpos);
}
//does not work //does not work
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \ // #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
@ -510,7 +680,7 @@ void MainMenu::showControlTemp()
if(force_lcd_update) if(force_lcd_update)
{ {
lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:"); lcd.setCursor(0,line);lcdprintPGM(" \002Nozzle:");
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degHotend0()))); lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
} }
if((activeline==line) ) if((activeline==line) )
@ -520,7 +690,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging; linechanging=!linechanging;
if(linechanging) if(linechanging)
{ {
encoderpos=intround(degHotend0()); encoderpos=intround(degTargetHotend0());
} }
else else
{ {
@ -558,10 +728,7 @@ void MainMenu::showControlTemp()
} }
else else
{ {
fanpwm = constrain(encoderpos,0,255); encoderpos=activeline*lcdslow;
encoderpos=fanpwm;
analogWrite(FAN_PIN, fanpwm);
beepshort(); beepshort();
} }
BLOCK; BLOCK;
@ -1246,7 +1413,22 @@ void MainMenu::showMainMenu()
#ifndef ULTIPANEL #ifndef ULTIPANEL
force_lcd_update=false; force_lcd_update=false;
#endif #endif
if(tune)
{
if(!(movesplanned() ||card.sdprinting))
{
force_lcd_update=true;
tune=false;
}
}
else
{
if(movesplanned() ||card.sdprinting)
{
force_lcd_update=true;
tune=true;
}
}
clearIfNecessary(); clearIfNecessary();
for(int8_t line=0;line<LCD_HEIGHT;line++) for(int8_t line=0;line<LCD_HEIGHT;line++)
{ {
@ -1256,7 +1438,7 @@ void MainMenu::showMainMenu()
MENUITEM( lcdprintPGM(" Watch") , BLOCK;status=Main_Status;beepshort(); ) ; MENUITEM( lcdprintPGM(" Watch") , BLOCK;status=Main_Status;beepshort(); ) ;
break; break;
case ItemM_prepare: case ItemM_prepare:
MENUITEM( lcdprintPGM(" Prepare \x7E") , BLOCK;status=Main_Prepare;beepshort(); ) ; MENUITEM( if(!tune) lcdprintPGM(" Prepare \x7E");else lcdprintPGM(" Tune \x7E"); , BLOCK;status=Main_Prepare;beepshort(); ) ;
break; break;
case ItemM_control: case ItemM_control:
@ -1363,7 +1545,14 @@ void MainMenu::update()
}break; }break;
case Main_Prepare: case Main_Prepare:
{ {
showPrepare(); if(tune)
{
showTune();
}
else
{
showPrepare();
}
}break; }break;
case Main_Control: case Main_Control:
{ {
@ -1478,26 +1667,6 @@ char *ftostr51(const float &x)
return conv; return conv;
} }
char *fillto(int8_t n,char *c)
{
static char ret[25];
bool endfound=false;
for(int8_t i=0;i<n;i++)
{
ret[i]=c[i];
if(c[i]==0)
{
endfound=true;
}
if(endfound)
{
ret[i]=' ';
}
}
ret[n]=0;
return ret;
}
#endif //ULTRA_LCD #endif //ULTRA_LCD

Loading…
Cancel
Save