@ -3,6 +3,9 @@
#include "ultralcd.h"
#ifdef ULTRA_LCD
#include "Marlin.h"
#include "language.h"
#include "temperature.h"
#include "EEPROMwrite.h"
#include <LiquidCrystal.h>
//===========================================================================
//=============================imported variables============================
@ -15,6 +18,7 @@ extern volatile int extrudemultiply;
extern long position[4];
#ifdef SDSUPPORT
#include "cardreader.h"
extern CardReader card;
#endif
@ -22,7 +26,7 @@ extern CardReader card;
//=============================public variables============================
//===========================================================================
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
long encoderpos=0;
short lastenc=0;
@ -97,6 +101,9 @@ FORCE_INLINE void clear()
void lcd_init()
{
//beep();
#ifdef ULTIPANEL
buttons_init();
#endif
byte Degree[8] =
{
@ -304,10 +311,6 @@ MainMenu::MainMenu()
displayStartingRow=0;
activeline=0;
force_lcd_update=true;
#ifdef ULTIPANEL
buttons_init();
#endif
lcd_init();
linechanging=false;
tune=false;
}
@ -884,7 +887,7 @@ void MainMenu::showTune()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3 ]));
lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS ]));
}
if((activeline!=line) )
@ -895,14 +898,14 @@ void MainMenu::showTune()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3] ;
encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0) ;
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3 ]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS ]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3 ]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
//current_position[E_AXIS ]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos/100.0 ;
encoderpos=activeline*lcdslow;
}
@ -912,8 +915,8 @@ void MainMenu::showTune()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos ));
if(encoderpos>999999 ) encoderpos=99 9999;
lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0 ));
}
}break;
@ -1296,7 +1299,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )Kp;
encoderpos=(long )Kp;
}
else
{
@ -1331,7 +1334,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )(Ki*10/PID_dT);
encoderpos=(long )(Ki*10/PID_dT);
}
else
{
@ -1367,7 +1370,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )(Kd/5./PID_dT);
encoderpos=(long )(Kd/5./PID_dT);
}
else
{
@ -1403,7 +1406,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )Kc;
encoderpos=(long )Kc;
}
else
{
@ -1476,7 +1479,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )acceleration/100;
encoderpos=(long )acceleration/100;
}
else
{
@ -1510,7 +1513,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )max_xy_jerk;
encoderpos=(long )max_xy_jerk;
}
else
{
@ -1553,7 +1556,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )max_feedrate[i-ItemCM_vmaxx];
encoderpos=(long )max_feedrate[i-ItemCM_vmaxx];
}
else
{
@ -1589,7 +1592,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )(minimumfeedrate);
encoderpos=(long )(minimumfeedrate);
}
else
{
@ -1624,7 +1627,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )mintravelfeedrate;
encoderpos=(long )mintravelfeedrate;
}
else
{
@ -1667,7 +1670,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
encoderpos=(long )max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
}
else
{
@ -1701,7 +1704,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int )retract_acceleration/100;
encoderpos=(long )retract_acceleration/100;
}
else
{
@ -1725,7 +1728,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0 ]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS ]));
}
if((activeline!=line) )
@ -1736,13 +1739,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[0 ]*100.0);
encoderpos=(long)(axis_steps_per_unit[X_AXIS ]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0 ]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS ]);
position[X_AXIS]=lround(position[X_AXIS]*factor);
//current_position[3 ]*=factor;
//current_position[X_AXIS ]*=factor;
axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
}
@ -1752,7 +1755,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>32000) encoderpos=32000;//TODO: This is a problem, encoderpos is 16bit, but steps_per_unit for e can be wel over 800
if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@ -1762,7 +1765,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1 ]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS ]));
}
if((activeline!=line) )
@ -1773,13 +1776,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[1 ]*100.0);
encoderpos=(long)(axis_steps_per_unit[Y_AXIS ]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1 ]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS ]);
position[Y_AXIS]=lround(position[Y_AXIS]*factor);
//current_position[3 ]*=factor;
//current_position[Y_AXIS ]*=factor;
axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
@ -1790,7 +1793,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
if(encoderpos>999999 ) encoderpos=99 9999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@ -1800,7 +1803,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2 ]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS ]));
}
if((activeline!=line) )
@ -1811,13 +1814,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[2 ]*100.0);
encoderpos=(long)(axis_steps_per_unit[Z_AXIS ]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2 ]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS ]);
position[Z_AXIS]=lround(position[Z_AXIS]*factor);
//current_position[3 ]*=factor;
//current_position[Z_AXIS ]*=factor;
axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
@ -1828,7 +1831,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
if(encoderpos>999999 ) encoderpos=99 9999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@ -1839,7 +1842,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3 ]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS ]));
}
if((activeline!=line) )
@ -1850,13 +1853,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[3 ]*100.0);
encoderpos=(long)(axis_steps_per_unit[E_AXIS ]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3 ]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS ]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3 ]*=factor;
//current_position[E_AXIS ]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
@ -1867,7 +1870,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
if(encoderpos>999999 ) encoderpos=99 9999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@ -2108,9 +2111,10 @@ void MainMenu::showMainMenu()
}
}
clearIfNecessary();
for(int8_t line=0;line<LCD_HEIGHT;line++)
uint8_t line=0;
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(l ine )
switch(i)
{
case ItemM_watch:
MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
@ -2164,6 +2168,7 @@ void MainMenu::showMainMenu()
SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
break;
}
line++;
}
updateActiveLines(3,encoderpos);
}
@ -2381,4 +2386,4 @@ char *ftostr52(const float &x)
#endif //ULTRA_LCD