@ -114,11 +114,13 @@ void lcd_init()
};
};
byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
byte uplevel[8]={0x04, 0x0e, 0x1f, 0x04, 0x1c, 0x00, 0x00, 0x00};//thanks joris
byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
byte refresh[8]={0x00, 0x06, 0x19, 0x18, 0x03, 0x13, 0x0c, 0x00}; //thanks joris
byte folder [8]={0x00, 0x1c, 0x1f, 0x11, 0x11, 0x1f, 0x00, 0x00}; //thanks joris
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.createChar(1,Degree);
lcd.createChar(1,Degree);
lcd.createChar(2,Thermometer);
lcd.createChar(2,Thermometer);
lcd.createChar(3,uplevel);
lcd.createChar(3,uplevel);
lcd.createChar(4,refresh);
lcd.createChar(4,refresh);
lcd.createChar(5,folder);
LCD_MESSAGEPGM("UltiMarlin ready.");
LCD_MESSAGEPGM("UltiMarlin ready.");
}
}
@ -224,6 +226,7 @@ void buttons_check()
buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
buttons=~newbutton; //invert it, because a pressed switch produces a logical 0
#endif
#endif
//manage encoder rotation
char enc=0;
char enc=0;
if(buttons&EN_A)
if(buttons&EN_A)
enc|=(1<<0);
enc|=(1<<0);
@ -279,7 +282,6 @@ MainMenu::MainMenu()
linechanging=false;
linechanging=false;
}
}
void MainMenu::showStatus()
void MainMenu::showStatus()
{
{
#if LCD_HEIGHT==4
#if LCD_HEIGHT==4
@ -319,7 +321,7 @@ void MainMenu::showStatus()
{
{
lcd.setCursor(1,0);
lcd.setCursor(1,0);
lcd.print(ftostr3(tBed));
lcd.print(ftostr3(tBed));
olddegHotEnd0 =tBed;
oldtBed =tBed;
}
}
int targetBed=intround(degTargetBed());
int targetBed=intround(degTargetBed());
if((targetBed!=oldtargetBed)||force_lcd_update)
if((targetBed!=oldtargetBed)||force_lcd_update)
@ -422,173 +424,88 @@ void MainMenu::showStatus()
}
}
#endif
#endif
force_lcd_update=false;
}
}
enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep};
//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) && CLICKED) {click_action} \
}
void MainMenu::showPrepare()
void MainMenu::showPrepare()
{
{
uint8_t line=0;
uint8_t line=0;
if(lastlineoffset!=lineoffset)
clearIfNecessary();
{
force_lcd_update=true;
clear();
}
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
{
//Serial.println((int)(line-lineoffset));
//Serial.println((int)(line-lineoffset));
switch(i)
switch(i)
{
{
case ItemP_exit:
case ItemP_exit:
{
MENUITEM( lcdprintPGM(" Prepare") , BLOCK;status=Main_Menu;beepshort(); ) ;
if(force_lcd_update)
break;
{
lcd.setCursor(0,line);lcdprintPGM(" Prepare");
}
if((activeline==line) && CLICKED)
{
BLOCK
status=Main_Menu;
beepshort();
}
}break;
case ItemP_home:
case ItemP_home:
{
MENUITEM( lcdprintPGM(" Auto Home") , BLOCK;enquecommand("G28 X-105 Y-105 Z0");beepshort(); ) ;
if(force_lcd_update)
break;
{
lcd.setCursor(0,line);lcdprintPGM(" Auto Home");
}
if((activeline==line) && CLICKED)
{
BLOCK
enquecommand("G28 X-105 Y-105 Z0");
beepshort();
}
}break;
case ItemP_origin:
case ItemP_origin:
{
MENUITEM( lcdprintPGM(" Set Origin") , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
if(force_lcd_update)
break;
{
lcd.setCursor(0,line);lcdprintPGM(" Set Origin");
}
if((activeline==line) && CLICKED)
{
BLOCK
enquecommand("G92 X0 Y0 Z0");
beepshort();
}
}break;
case ItemP_preheat:
case ItemP_preheat:
{
MENUITEM( lcdprintPGM(" Preheat") , BLOCK;setTargetHotend0(170);beepshort(); ) ;
if(force_lcd_update)
break;
{
lcd.setCursor(0,line);lcdprintPGM(" Preheat");
}
if((activeline==line) && CLICKED)
{
BLOCK
setTargetHotend0(170);
beepshort();
}
}break;
case ItemP_extrude:
case ItemP_extrude:
{
MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
if(force_lcd_update)
break;
{
lcd.setCursor(0,line);lcdprintPGM(" Extrude");
}
if((activeline==line) && CLICKED)
{
BLOCK
enquecommand("G92 E0");
enquecommand("G1 F700 E50");
beepshort();
}
}break;
case ItemP_disstep:
case ItemP_disstep:
{
MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ;
if(force_lcd_update)
break;
{
lcd.setCursor(0,line);lcdprintPGM(" Disable Steppers");
}
if((activeline==line) && CLICKED)
{
BLOCK
enquecommand("M84");
beepshort();
}
}break;
default:
default:
break;
break;
}
}
line++;
line++;
}
}
lastlineoffset=lineoffset;
updateActiveLines(ItemP_disstep,encoderpos);
if((encoderpos/lcdslow!=lastencoderpos/lcdslow)||force_lcd_update)
}
{
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
if(encoderpos<0)
//does not work
{
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
lineoffset--;
// {\
if(lineoffset<0)
// if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
lineoffset=0;
// if(activeline==line) \
encoderpos=0;
// { \
force_lcd_update=true;
// if(CLICKED) \
}
// { \
if(encoderpos/lcdslow>3)
// linechanging=!linechanging; \
{
// if(linechanging) {enter_action;} \
lineoffset++;
// else {accept_action;} \
encoderpos=3*lcdslow;
// } \
if(lineoffset>(ItemP_disstep+1-LCD_HEIGHT))
// else \
lineoffset=ItemP_disstep+1-LCD_HEIGHT;
// if(linechanging) {change_action};}\
force_lcd_update=true;
// }
}
//
//encoderpos=encoderpos%LCD_HEIGHT;
lastencoderpos=encoderpos;
activeline=encoderpos/lcdslow;
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
}
}
enum {
enum {
ItemC_exit, ItemC_nozzle,
ItemCT_exit, ItemCT_nozzle, ItemCT_fan,
ItemC_PID_P,ItemC_PID_I,ItemC_PID_D,ItemC_PID_C,
ItemCT_PID_P,ItemCT_PID_I,ItemCT_PID_D,ItemCT_PID_C
ItemC_fan,
ItemC_acc, ItemC_xyjerk,
ItemC_vmaxx, ItemC_vmaxy, ItemC_vmaxz, ItemC_vmaxe,
ItemC_vtravmin,ItemC_vmin,
ItemC_amaxx, ItemC_amaxy, ItemC_amaxz, ItemC_amaxe,
ItemC_aret,ItemC_esteps, ItemC_store, ItemC_load,ItemC_failsafe
};
};
void MainMenu::showControl()
void MainMenu::showControlTemp()
{
{
uint8_t line=0;
uint8_t line=0;
if((lastlineoffset!=lineoffset)||force_lcd_update)
clearIfNecessary();
{
force_lcd_update=true;
clear();
}
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
{
switch(i)
switch(i)
{
{
case ItemC_exit:
case ItemCT_exit:
{
MENUITEM( lcdprintPGM(" Temperature") , BLOCK;status=Main_Control;beepshort(); ) ;
if(force_lcd_update)
break;
{
case ItemCT_nozzle:
lcd.setCursor(0,line);lcdprintPGM(" Control");
}
if((activeline==line) && CLICKED)
{
BLOCK
status=Main_Menu;
beepshort();
}
}break;
case ItemC_nozzle:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
@ -622,7 +539,7 @@ void MainMenu::showControl()
}
}
}break;
}break;
case ItemC_fan:
case ItemCT _fan:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
@ -659,12 +576,12 @@ void MainMenu::showControl()
}
}
}
}
}break;
}break;
case ItemC_acc:
case ItemCT_PID_P:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" Acc: ");
lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00" );
lcd.setCursor(13,line);lcd.print(itostr4(Kp) );
}
}
if((activeline==line) )
if((activeline==line) )
@ -674,30 +591,31 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)acceleration/100 ;
encoderpos=(int)Kp/5 ;
}
}
else
else
{
{
acceleration= encoderpos*100 ;
Kp= encoderpos*5 ;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
BLOCK;
BLOCK;
beepshort();
beepshort();
}
}
if(linechanging)
if(linechanging)
{
{
if(encoderpos<5) encoderpos=5 ;
if(encoderpos<1) encoderpos=1 ;
if(encoderpos>990) encoderpos=990;
if(encoderpos>999 0/5 ) encoderpos=999 0/5 ;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00" );
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5) );
}
}
}
}
}break;
}break;
case ItemC_xyjerk: //max_xy_jerk
case ItemCT_PID_I:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk : ");
lcd.setCursor(0,line);lcdprintPGM(" PID-I : ");
lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk ));
lcd.setCursor(13,line);lcd.print(ftostr51(Ki ));
}
}
if((activeline==line) )
if((activeline==line) )
@ -707,11 +625,11 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)max_xy_jerk ;
encoderpos=(int)(Ki*10) ;
}
}
else
else
{
{
max_xy_jerk= encoderpos ;
Ki= encoderpos/10. ;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
@ -720,18 +638,18 @@ void MainMenu::showControl()
}
}
if(linechanging)
if(linechanging)
{
{
if(encoderpos<1) encoderpos=1 ;
if(encoderpos<0) encoderpos=0 ;
if(encoderpos>990) encoderpos=990;
if(encoderpos>999 0) encoderpos=9 990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos ));
lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10. ));
}
}
}
}
}break;
}break;
case ItemC_PID_P :
case ItemCT_PID_D :
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" PID-P : ");
lcd.setCursor(0,line);lcdprintPGM(" PID-D : ");
lcd.setCursor(13,line);lcd.print(itostr4(Kp ));
lcd.setCursor(13,line);lcd.print(itostr4(Kd ));
}
}
if((activeline==line) )
if((activeline==line) )
@ -741,11 +659,11 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)Kp /5;
encoderpos=(int)Kd /5;
}
}
else
else
{
{
Kp = encoderpos*5;
Kd = encoderpos*5;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
@ -754,18 +672,19 @@ void MainMenu::showControl()
}
}
if(linechanging)
if(linechanging)
{
{
if(encoderpos<1) encoderpos=1 ;
if(encoderpos<0) encoderpos=0 ;
if(encoderpos>9990/5) encoderpos=9990/5;
if(encoderpos>9990/5) encoderpos=9990/5;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
}
}
}
}
}break;
}break;
case ItemC_PID_I:
case ItemCT_PID_C:
#ifdef PID_ADD_EXTRUSION_RATE
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" PID-I : ");
lcd.setCursor(0,line);lcdprintPGM(" PID-C : ");
lcd.setCursor(13,line);lcd.print(ftostr51(Ki ));
lcd.setCursor(13,line);lcd.print(itostr3(Kc ));
}
}
if((activeline==line) )
if((activeline==line) )
@ -775,11 +694,11 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)(Ki*10) ;
encoderpos=(int)Kc ;
}
}
else
else
{
{
Ki= encoderpos/10. ;
Kc= encoderpos ;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
@ -789,17 +708,54 @@ void MainMenu::showControl()
if(linechanging)
if(linechanging)
{
{
if(encoderpos<0) encoderpos=0;
if(encoderpos<0) encoderpos=0;
if(encoderpos>999 0) encoderpos=9 990;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(ftostr51(encoderpos/10. ));
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos ));
}
}
}
}
}break;
}
case ItemC_PID_D:
#endif
break;
default:
break;
}
line++;
}
#ifdef PID_ADD_EXTRUSION_RATE
updateActiveLines(ItemCT_PID_C,encoderpos);
#else
updateActiveLines(ItemCT_PID_D,encoderpos);
#endif
}
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_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( lcdprintPGM(" Motion") , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCM_acc:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" PID-D: ");
lcd.setCursor(0,line);lcdprintPGM(" Acc: ");
lcd.setCursor(13,line);lcd.print(itostr4(Kd));
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00" );
}
}
if((activeline==line) )
if((activeline==line) )
@ -809,34 +765,30 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)Kd/5 ;
encoderpos=(int)acceleration/100 ;
}
}
else
else
{
{
Kd= encoderpos*5 ;
acceleration= encoderpos*100 ;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
BLOCK;
BLOCK;
beepshort();
beepshort();
}
}
if(linechanging)
if(linechanging)
{
{
if(encoderpos<0) encoderpos=0 ;
if(encoderpos<5) encoderpos=5 ;
if(encoderpos>999 0/5 ) encoderpos=999 0/5 ;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5) );
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00" );
}
}
}
}
}break;
}break;
case ItemCM_xyjerk: //max_xy_jerk
case ItemC_PID_C:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" PID-C : ");
lcd.setCursor(0,line);lcdprintPGM(" Vxy-jerk : ");
lcd.setCursor(13,line);lcd.print(itostr3(Kc ));
lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk ));
}
}
if((activeline==line) )
if((activeline==line) )
@ -846,11 +798,11 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)Kc ;
encoderpos=(int)max_xy_jerk ;
}
}
else
else
{
{
Kc = encoderpos;
max_xy_jerk = encoderpos;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
@ -859,25 +811,26 @@ void MainMenu::showControl()
}
}
if(linechanging)
if(linechanging)
{
{
if(encoderpos<0) encoderpos=0 ;
if(encoderpos<1) encoderpos=1 ;
if(encoderpos>990) encoderpos=990;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}
}
}
}break;
}break;
case ItemC_vmaxx:
case ItemC_vmaxy:
case ItemCM_vmaxx:
case ItemC_vmaxz:
case ItemCM_vmaxy:
case ItemC_vmaxe:
case ItemCM_vmaxz:
case ItemCM_vmaxe:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
lcd.setCursor(0,line);lcdprintPGM(" Vmax ");
if(i==ItemC_vmaxx)lcdprintPGM("x:");
if(i==ItemCM _vmaxx)lcdprintPGM("x:");
if(i==ItemC_vmaxy)lcdprintPGM("y:");
if(i==ItemCM _vmaxy)lcdprintPGM("y:");
if(i==ItemC_vmaxz)lcdprintPGM("z:");
if(i==ItemCM _vmaxz)lcdprintPGM("z:");
if(i==ItemC_vmaxe)lcdprintPGM("e:");
if(i==ItemCM _vmaxe)lcdprintPGM("e:");
lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemC_vmaxx]));
lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM _vmaxx]));
}
}
if((activeline==line) )
if((activeline==line) )
@ -887,11 +840,11 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)max_feedrate[i-ItemC_vmaxx];
encoderpos=(int)max_feedrate[i-ItemCM _vmaxx];
}
}
else
else
{
{
max_feedrate[i-ItemC_vmaxx]= encoderpos;
max_feedrate[i-ItemCM _vmaxx]= encoderpos;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
@ -907,7 +860,7 @@ void MainMenu::showControl()
}
}
}break;
}break;
case ItemC_vmin:
case ItemCM _vmin:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
@ -941,7 +894,7 @@ void MainMenu::showControl()
}
}
}
}
}break;
}break;
case ItemC_vtravmin:
case ItemCM _vtravmin:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
@ -976,19 +929,19 @@ void MainMenu::showControl()
}
}
}break;
}break;
case ItemC_amaxx:
case ItemCM _amaxx:
case ItemC_amaxy:
case ItemCM _amaxy:
case ItemC_amaxz:
case ItemCM _amaxz:
case ItemC_amaxe:
case ItemCM _amaxe:
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
lcd.setCursor(0,line);lcdprintPGM(" Amax ");
lcd.setCursor(0,line);lcdprintPGM(" Amax ");
if(i==ItemC_amaxx)lcdprintPGM("x:");
if(i==ItemCM _amaxx)lcdprintPGM("x:");
if(i==ItemC_amaxy)lcdprintPGM("y:");
if(i==ItemCM _amaxy)lcdprintPGM("y:");
if(i==ItemC_amaxz)lcdprintPGM("z:");
if(i==ItemCM _amaxz)lcdprintPGM("z:");
if(i==ItemC_amaxe)lcdprintPGM("e:");
if(i==ItemCM _amaxe)lcdprintPGM("e:");
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemC_amaxx]/100));lcdprintPGM("00");
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM _amaxx]/100));lcdprintPGM("00");
}
}
if((activeline==line) )
if((activeline==line) )
@ -998,11 +951,11 @@ void MainMenu::showControl()
linechanging=!linechanging;
linechanging=!linechanging;
if(linechanging)
if(linechanging)
{
{
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemC_amaxx]/100;
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM _amaxx]/100;
}
}
else
else
{
{
max_acceleration_units_per_sq_second[i-ItemC_amaxx]= encoderpos*100;
max_acceleration_units_per_sq_second[i-ItemCM _amaxx]= encoderpos*100;
encoderpos=activeline*lcdslow;
encoderpos=activeline*lcdslow;
}
}
BLOCK;
BLOCK;
@ -1016,7 +969,7 @@ void MainMenu::showControl()
}
}
}
}
}break;
}break;
case ItemC_aret://float retract_acceleration = 7000;
case ItemCM _aret://float retract_acceleration = 7000;
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
@ -1050,7 +1003,7 @@ void MainMenu::showControl()
}
}
}
}
}break;
}break;
case ItemC_esteps://axis_steps_per_unit[i] = code_value();
case ItemCM _esteps://axis_steps_per_unit[i] = code_value();
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
@ -1087,6 +1040,37 @@ void MainMenu::showControl()
}
}
}
}
}break;
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemCM_esteps,encoderpos);
}
enum {
ItemC_exit,ItemC_temp,ItemC_move,
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( lcdprintPGM(" Control \x7E") , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemC_temp:
MENUITEM( lcdprintPGM(" Temperature \x7E") , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemC_move:
MENUITEM( lcdprintPGM(" Motion \x7E") , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
break;
case ItemC_store:
case ItemC_store:
{
{
if(force_lcd_update)
if(force_lcd_update)
@ -1134,37 +1118,8 @@ void MainMenu::showControl()
}
}
line++;
line++;
}
}
lastlineoffset=lineoffset;
updateActiveLines(ItemC_failsafe,encoderpos);
if(!linechanging && ((encoderpos/lcdslow!=lastencoderpos/lcdslow)||force_lcd_update))
{
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
if(encoderpos<0)
{
lineoffset--;
if(lineoffset<0)
lineoffset=0;
encoderpos=0;
force_lcd_update=true;
}
}
if(encoderpos/lcdslow>3)
{
lineoffset++;
encoderpos=3*lcdslow;
if(lineoffset>(ItemC_failsafe+1-LCD_HEIGHT))
lineoffset=ItemC_failsafe+1-LCD_HEIGHT;
force_lcd_update=true;
}
//encoderpos=encoderpos%LCD_HEIGHT;
lastencoderpos=encoderpos;
activeline=encoderpos/lcdslow;
if(activeline>3) activeline=3;
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
}
}
@ -1175,14 +1130,10 @@ void MainMenu::showSD()
#ifdef SDSUPPORT
#ifdef SDSUPPORT
uint8_t line=0;
uint8_t line=0;
if(lastlineoffset!=lineoffset)
clearIfNecessary();
{
force_lcd_update=true;
}
static uint8_t nrfiles=0;
static uint8_t nrfiles=0;
if(force_lcd_update)
if(force_lcd_update)
{
{
clear();
if(card.cardOK)
if(card.cardOK)
{
{
nrfiles=card.getnrfilenames();
nrfiles=card.getnrfilenames();
@ -1192,68 +1143,74 @@ void MainMenu::showSD()
nrfiles=0;
nrfiles=0;
lineoffset=0;
lineoffset=0;
}
}
//Serial.print("Nr files:"); Serial.println((int)nrfiles);
}
}
bool enforceupdate=false;
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
{
switch(i)
switch(i)
{
{
case 0:
case 0:
{
MENUITEM( lcdprintPGM(" File") , BLOCK;status=Main_Menu;beepshort(); ) ;
if(force_lcd_update)
break;
{
// case 1:
lcd.setCursor(0,line);lcdprintPGM(" File");
// {
}
// if(force_lcd_update)
if((activeline==line) && CLICKED)
// {
{
// lcd.setCursor(0,line);
BLOCK
// #ifdef CARDINSERTED
status=Main_Menu;
// if(CARDINSERTED)
beepshort();
// #else
}
// if(true)
}break;
// #endif
// {
// lcdprintPGM(" \004Refresh");
// }
// else
// {
// lcdprintPGM(" \004Insert Card");
// }
//
// }
// if((activeline==line) && CLICKED)
// {
// BLOCK;
// beepshort();
// card.initsd();
// force_lcd_update=true;
// nrfiles=card.getnrfilenames();
// }
// }break;
case 1:
case 1:
{
MENUITEM( lcdprintPGM(" ..") , BLOCK;card.updir();enforceupdate=true;lineoffset=0;beepshort(); ) ;
if(force_lcd_update)
{
lcd.setCursor(0,line);
#ifdef CARDINSERTED
if(CARDINSERTED)
#else
if(true)
#endif
{
lcdprintPGM(" \004Refresh");
}
else
{
lcdprintPGM(" \004Insert Card");
}
}
break;
if((activeline==line) && CLICKED)
{
BLOCK;
beepshort();
card.initsd();
force_lcd_update=true;
nrfiles=card.getnrfilenames();
}
}break;
default:
default:
{
{
if(i-2<nrfiles)
#define FIRSTITEM 2
if(i-FIRSTITEM<nrfiles)
{
{
if(force_lcd_update)
if(force_lcd_update)
{
{
card.getfilename(i-2 );
card.getfilename(i-FIRSTITEM);
//Serial.print("Filenr:");Serial.println(i-2);
//Serial.print("Filenr:");Serial.println(i-2);
lcd.setCursor(0,line);lcdprintPGM(" ");lcd.print(card.filename);
lcd.setCursor(0,line);lcdprintPGM(" ");
if(card.filenameIsDir) lcd.print("\005");
lcd.print(card.filename);
}
}
if((activeline==line) && CLICKED)
if((activeline==line) && CLICKED)
{
{
BLOCK
BLOCK
card.getfilename(i-2);
card.getfilename(i-FIRSTITEM);
if(card.filenameIsDir)
{
for(int8_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];
char cmd[30];
for(int8_t i=0;i<strlen(card.filename);i++)
for(int8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
card.filename[i]=tolower(card.filename[i]);
@ -1266,49 +1223,18 @@ void MainMenu::showSD()
lcd_status(card.filename);
lcd_status(card.filename);
}
}
}
}
}
}
}
break;
break;
}
}
line++;
line++;
}
}
lastlineoffset=lineoffset;
updateActiveLines(FIRSTITEM+nrfiles-1,encoderpos);
if((encoderpos!=lastencoderpos)||force_lcd_update)
if(enforceupdate)
{
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
if(encoderpos<0)
{
lineoffset--;
if(lineoffset<0)
lineoffset=0;
encoderpos=0;
force_lcd_update=true;
}
if(encoderpos/lcdslow>3)
{
{
lineoffset++;
encoderpos=3*lcdslow;
if(lineoffset>(1+nrfiles+1-LCD_HEIGHT))
lineoffset=1+nrfiles+1-LCD_HEIGHT;
force_lcd_update=true;
force_lcd_update=true;
enforceupdate=false;
}
lastencoderpos=encoderpos;
activeline=encoderpos;
if(activeline>3)
{
activeline=3;
}
if(activeline<0)
{
activeline=0;
}
if(activeline>1+nrfiles) activeline=1+nrfiles;
if(lineoffset>1+nrfiles) lineoffset=1+nrfiles;
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
}
}
#endif
#endif
}
}
@ -1316,49 +1242,26 @@ void MainMenu::showSD()
enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file };
enum {ItemM_watch, ItemM_prepare, ItemM_control, ItemM_file };
void MainMenu::showMainMenu()
void MainMenu::showMainMenu()
{
{
//if(int(encoderpos/lcdslow)!=int(lastencoderpos/lcdslow))
// force_lcd_update=true;
#ifndef ULTIPANEL
#ifndef ULTIPANEL
force_lcd_update=false;
force_lcd_update=false;
#endif
#endif
//Serial.println((int)activeline);
if(force_lcd_update)
clearIfNecessary();
clear();
for(int8_t line=0;line<LCD_HEIGHT;line++)
for(int8_t line=0;line<LCD_HEIGHT;line++)
{
{
switch(line)
switch(line)
{
{
case ItemM_watch:
case ItemM_watch:
{
MENUITEM( lcdprintPGM(" Watch") , BLOCK;status=Main_Status;beepshort(); ) ;
if(force_lcd_update) {lcd.setCursor(0,line);lcdprintPGM(" Watch \x7E");}
break;
if((activeline==line)&&CLICKED)
{
BLOCK;
beepshort();
status=Main_Status;
}
} break;
case ItemM_prepare:
case ItemM_prepare:
{
MENUITEM( lcdprintPGM(" Prepare \x7E") , BLOCK;status=Main_Prepare;beepshort(); ) ;
if(force_lcd_update) {lcd.setCursor(0,line);lcdprintPGM(" Prepare \x7E");}
break;
if((activeline==line)&&CLICKED)
{
BLOCK;
status=Main_Prepare;
beepshort();
}
} break;
case ItemM_control:
case ItemM_control:
{
MENUITEM( lcdprintPGM(" Control \x7E") , BLOCK;status=Main_Control;beepshort(); ) ;
if(force_lcd_update) {lcd.setCursor(0,line);lcdprintPGM(" Control \x7E");}
break;
if((activeline==line)&&CLICKED)
{
BLOCK;
status=Main_Control;
beepshort();
}
}break;
#ifdef SDSUPPORT
#ifdef SDSUPPORT
case ItemM_file:
case ItemM_file:
{
{
@ -1392,6 +1295,9 @@ void MainMenu::showMainMenu()
beepshort();
beepshort();
}
}
}break;
}break;
#else
case ItemM_file:
break;
#endif
#endif
default:
default:
SERIAL_ERROR_START;
SERIAL_ERROR_START;
@ -1399,24 +1305,7 @@ void MainMenu::showMainMenu()
break;
break;
}
}
}
}
if(activeline<0)
updateActiveLines(3,encoderpos);
activeline=0;
if(activeline>=LCD_HEIGHT)
activeline=LCD_HEIGHT-1;
if((encoderpos!=lastencoderpos)||force_lcd_update)
{
lcd.setCursor(0,activeline);lcd.print(activeline?' ':' ');
if(encoderpos<0) encoderpos=0;
if(encoderpos>3*lcdslow)
encoderpos=3*lcdslow;
activeline=abs(encoderpos/lcdslow)%LCD_HEIGHT;
if(activeline<0)
activeline=0;
if(activeline>=LCD_HEIGHT)
activeline=LCD_HEIGHT-1;
lastencoderpos=encoderpos;
lcd.setCursor(0,activeline);lcd.print(activeline?'>':'\003');
}
}
}
void MainMenu::update()
void MainMenu::update()
@ -1433,20 +1322,18 @@ void MainMenu::update()
if(CARDINSERTED)
if(CARDINSERTED)
{
{
card.initsd();
card.initsd();
lcd_status ("Card inserted");
LCD_MESSAGEPGM ("Card inserted");
}
}
else
else
{
{
card.release();
card.release();
lcd_status ("Card removed");
LCD_MESSAGEPGM ("Card removed");
}
}
}
}
#endif
#endif
if(status!=oldstatus)
if(status!=oldstatus)
{
{
//Serial.println(status);
//clear();
force_lcd_update=true;
force_lcd_update=true;
encoderpos=0;
encoderpos=0;
lineoffset=0;
lineoffset=0;
@ -1482,6 +1369,14 @@ void MainMenu::update()
{
{
showControl();
showControl();
}break;
}break;
case Sub_MotionControl:
{
showControlMotion();
}break;
case Sub_TempControl:
{
showControlTemp();
}break;
case Main_SD:
case Main_SD:
{
{
showSD();
showSD();
@ -1490,7 +1385,7 @@ void MainMenu::update()
if(timeoutToStatus<millis())
if(timeoutToStatus<millis())
status=Main_Status;
status=Main_Status;
force_lcd_update=false;
// force_lcd_update=false;
lastencoderpos=encoderpos;
lastencoderpos=encoderpos;
}
}